# !/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time : 3/19/21 6:04 PM
# @Author : minvan
# @Email : jiangming8937@icloud.com
# @File : SassWeb.py
# @Software: PyCharm

import os
import configparser
import requests
import json
import logging
import sys


class Config():
    '''
    解析配置文件
    '''
    def __init__(self):
        pass

    @staticmethod
    def GetConfig(environment = "Beta"):
        '''
        :param environment: 选择对应环境 Pro=线上 Beta=Beta Dev=Dev
        :returns: HeyuAPPDomians:域名地址
        :returns: HeyuWebDomains:域名地址
        :returns: CommontParams:返回公共参数 app p
        :returns: Driver1 Driver2:两位司机的手机号码
        '''
        cf = configparser.ConfigParser()
        path = os.path.dirname(os.path.abspath(__file__))
        cf.read(filenames=path+"/Commonconfig.ini",encoding="utf8")
        SassWebDomains = cf.get(section=environment,option='HeyuWeb')
        SassWebUser = cf.get(section="User",option='User')
        return SassWebDomains,SassWebUser



class Heyuweb(Config):

    def __init__(self):
        self.Domains = Config.GetConfig()[0]
        self.User = Config.GetConfig()[1]


    def WebLogin(self):
        Url = self.Domains + "/webapi/user/login/"
        print(Url)
        Params = {"authType":"authcode","loginName":self.User,"password":"0000","verificationCode":"5KS6","sessionid":"9d6ffe92-c54f-488f-b404-493cd5adc832"}
        Resp = requests.post(url=Url,json=Params)
        CookieValue = Resp.cookies.get_dict()

        print(Resp.content.decode())

if __name__ == '__main__':
    Heyuweb().WebLogin()
